﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Monocle.DataModel;

namespace Monocle.Models
{
    public class FacebookViewModel
    {
        private tFacebook _dto;
        public FacebookViewModel(tFacebook dto)
        {
            _dto = dto;
        }

        public FacebookViewModel()
        {
            _dto = new tFacebook();
        }


        [HiddenInput(DisplayValue = false)]
        public Guid ModuleID
        {
            get { return _dto.PK_tFacebook; }
            set { _dto.PK_tFacebook = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public Guid FK_tPageItem
        {
            get { return _dto.FK_tPageItem; }
            set { _dto.FK_tPageItem = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public Guid FK_tPage { get; set; }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public byte[] Version
        {
            get { return _dto.Version; }
            set { _dto.Version = value; }

        }

        [Required(ErrorMessageResourceName = "Generic_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "Module_Facebook_ContentType", ResourceType = typeof(Resources.Monocle))]
        public String ContentType
        {
            get { return _dto.ContentType; }
            set { _dto.ContentType = value; }
        }

        [ScriptIgnore]
        [Required(ErrorMessageResourceName = "Generic_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "Module_Facebook_Limit", ResourceType = typeof(Resources.Monocle))]
        public int? Limit
        {
            get { return _dto.Limit; }
            set { _dto.Limit = value; }
        }

        [ScriptIgnore]
        [Required(ErrorMessageResourceName = "Generic_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "Module_Facebook_PageName", ResourceType = typeof(Resources.Monocle))]
        public String PageName
        {
            get { return _dto.Name; }
            set { _dto.Name = value; }
        }

        [ScriptIgnore]
        public String JSONCache
        {
            get { return _dto.JSONCache; }
            set { _dto.JSONCache = value; }
        }

        [ScriptIgnore]
        [Display(Name = "PageItemViewModel_Published", ResourceType = typeof(Resources.Monocle))]
        public bool Published { get; set; }

        public String FacebookStreamJSON { get; set; }

        [ScriptIgnore]
        [Required(ErrorMessageResourceName = "Generic_Required", ErrorMessageResourceType = typeof(Resources.Monocle))]
        [Display(Name = "PageItemViewModel_Name", ResourceType = typeof(Resources.Monocle))]
        public String PageItemName { get; set; }

        [ScriptIgnore]
        [Display(Name = "PageItemViewModel_GalleryID", ResourceType = typeof(Resources.Monocle))]
        public String GalleryID
        {
            get { return _dto.GalleryID; }
            set { _dto.GalleryID = value; }
        }

        [ScriptIgnore]
        [HiddenInput(DisplayValue = false)]
        public Dictionary<String, String> GalleryList { get; set; }

        /// <summary>
        /// Returns the DTO
        /// </summary>
        /// <returns></returns>
        public tFacebook ToDTO()
        {
            return _dto;
        }

        public void UpdateFromDTO(tFacebook dto)
        {
            _dto = dto;
        }
    }
}